Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support xz tarballs if available #823

Merged
merged 1 commit into from
Oct 8, 2015

Conversation

jbergstroem
Copy link
Contributor

Saves us ~25% bandwidth, but only nodejs 4.0.0 and forward. We check for the existence of xz so older versions or targets without it is unaffected.

@jbergstroem
Copy link
Contributor Author

(fwiw, not very happy with the DRY-ness of these checks but I followed the convention of not polluting the global scope)

@jbergstroem
Copy link
Contributor Author

Not sure why the test case wasn't executed.

Edit: most likely because I didn't even push it.... 😴

@jbergstroem jbergstroem force-pushed the feature/prefer-xz branch 2 times, most recently from 501731d to 3ce5a32 Compare September 10, 2015 01:05


OLDPATH=$PATH
export PATH=../../xz-test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will likely break things in tests - could you preserve the existing path, and prepend your new dir, rather than overwriting it entirely?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I previously had export PATH=$OLDPATH but since every test seems sourced separately I didn't see anything breaking. Happy to re-add? If I prepend dir we will very likely run into false positives since most machines we will be testing on already has xz installed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overwriting PATH means that any nvm internals relying on things that should be available via PATH will break - doing it in tests makes future refactoring of nvm more brittle, and doesn't accurately represent the user's environment.

I think that for the tests where zx is not installed - which ideally are in a separate test file from the ones testing that it is installed - should make whatever assertions or stubs are needed to cover that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Would juggling path (OLDPATH, PATH) inside of one file be good enough? Having two files would sort of break your unit test convention file layout.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand that part - our convention is as close to one test per file as possible. Perhaps you want to make a subdirectory for xz, and in that, use setup and teardown files, for the common code?

@ljharb ljharb added installing node Issues with installing node/io.js versions. feature requests I want a new feature in nvm! labels Sep 10, 2015
@@ -1999,6 +2031,10 @@ nvm_supports_source_options() {
[ "_$(echo 'echo $1' | . /dev/stdin yes 2> /dev/null)" = "_yes" ]
}

nvm_supports_xz() {
[ $(command which xz) ] && nvm_is_merged_node_version "$1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of a subshell, could this just be command which xz 2>&1 >/dev/null && nvm_is_merged_node_version "$1"?

@jbergstroem
Copy link
Contributor Author

Just following up here. I added stuff to teardown but never had it run if my test bailed early. As-is current PR at least works. Suggested next step?

@jbergstroem
Copy link
Contributor Author

The latest change should bail early and move the cleanup phase to teardown. I don't see where teardown is called though.

Edit: ah, part of urchin.

@@ -1999,6 +2015,10 @@ nvm_supports_source_options() {
[ "_$(echo 'echo $1' | . /dev/stdin yes 2> /dev/null)" = "_yes" ]
}

nvm_supports_xz() {
command which xz 2>&1 >/dev/null && nvm_is_merged_node_version "$1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make this return true for the appropriate io.js versions also?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. This is bit of a mixed bag though. We messed up during release phase, so xz tarballs for darwin is 2.3.2 and up whereas linux/src is 1.0.0 and up. Go with the safe option of 2.3.2 and up?

@jbergstroem jbergstroem force-pushed the feature/prefer-xz branch 3 times, most recently from 0661c9d to c360313 Compare October 8, 2015 05:32
Saves us ~25% bandwidth while downloading the payload. This only applies
to hosts that has the `xz` binary and attempts to use iojs 2.3.2 or newer
(this includes nodejs 4.0+ as well). Older targets are unaffected.
ljharb added a commit that referenced this pull request Oct 8, 2015
Support `xz` tarballs if available (on io.js >= 2.3.2 and node >= 4)
@ljharb ljharb merged commit 7028e5d into nvm-sh:master Oct 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature requests I want a new feature in nvm! installing node Issues with installing node/io.js versions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants